package com.ziyia.a14;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import java.io.Serializable;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    public void toast(View view) {
        Toast.makeText(MyApplication.conText, "年少有为" ,Toast.LENGTH_SHORT).show();
    }

    private void serializable() {
        Person person = new Person("Serializable", 18);
        Intent intent = new Intent(this, MainActivity2.class);
        intent.putExtra("person_data", person);
        startActivity(intent);

    }

    private void parcelable() {
        Person2 person2 = new Person2("Parcelable", 20);
        Intent intent = new Intent(this, MainActivity2.class);
        intent.putExtra("person2_data", person2);
        startActivity(intent);
    }

    public void parcelable(View view) {
        parcelable();
    }

    public void serializable(View view) {
        serializable();
    }
}